/**
 * @Title: HomeActivity.java
 * @Package com.sinoglobal.waitingMe.activity
 * @Description: TODO(用一句话描述该文件做什么)
 * @author hpq
 * @date 2015-8-30 上午11:55:09
 */

package com.sinoglobal.wallet.activity;

import java.math.BigDecimal;

import android.graphics.Typeface;
import android.os.Bundle;
import android.text.Html;
import android.text.TextPaint;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.sinoglobal.wallet.R;
import com.sinoglobal.wallet.util.NetWorkUtil;

/**
 * @author clf
 * @createdate 2015-10-26现详情)
 */
public class W_WithDrawalDetailActivity extends W_SinoBaseActivity {

	private TextView withDrawal_detail_commmit,withDrawal_detail_bank_name,withDrawal_detail_money,withDrawal_detail_instruction_txt;
	private TextView withDrawal_actual_money;
	private LinearLayout withDrawal_actual_money_layout;

	@Override
	protected void onCreate(Bundle arg0) {
		super.onCreate(arg0);
		setContentView(R.layout.wallet_withdrawal_detail_layout);
		mTemplateTitleText.setText("提现详情");
		initView();
		if(getIntent()!=null){
	        String bankName = getIntent().getStringExtra("BankName");
	        String money = getIntent().getStringExtra("Money");
	        String fees = getIntent().getStringExtra("fees");
	        String instrution = getIntent().getStringExtra("Instrution");
	        withDrawal_detail_instruction_txt.setText("提现申请成功！将"+instrution);
	        withDrawal_detail_bank_name.setText(bankName);
	        if (Double.valueOf(money) >= 50) {
	    		withDrawal_actual_money_layout.setVisibility(View.GONE);
	    		  withDrawal_detail_money.setText(Html.fromHtml("<font size=28px>"+String.format("%.2f", Double.valueOf(money))+"元</font>"));
	    		  withDrawal_detail_money.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD));//加粗
	    		withDrawal_detail_money.setTextColor(getResources().getColor(R.color.w_payPass_red));
	    	}else{
	    		BigDecimal b= new BigDecimal(money);
	    		BigDecimal c= new BigDecimal(fees);
	    		/*Double 	actual_money=Double.valueOf(money)-Double.valueOf(fees);
        		BigDecimal bd=new BigDecimal(actual_money);//提现1.2手续费1.0结果是0.1999999999999；避免double类型异常，用BigDecimal四舍五入；
        		bd=bd.setScale(2, BigDecimal.ROUND_HALF_UP);*/
	    		withDrawal_actual_money_layout.setVisibility(View.VISIBLE);
	    		  withDrawal_detail_money.setText(Html.fromHtml("<font size=28px>"+String.format("%.2f", Double.valueOf(money))+"元</font><font size=24px>(扣除手续费"+String.format("%.2f", Double.valueOf(fees))+"元)</font>")); 
	    		  withDrawal_actual_money.setText(String.format("%.2f", Double.valueOf(b.subtract(c).doubleValue()))+"元");
	    	}
	        
	        }
	}



	private void initView() {
	
		withDrawal_detail_bank_name = (TextView) findViewById(R.id.withDrawal_detail_bank_name);
		withDrawal_actual_money_layout = (LinearLayout) findViewById(R.id.withDrawal_actual_money_layout);
		withDrawal_actual_money = (TextView) findViewById(R.id.withDrawal_actual_money);
		withDrawal_detail_commmit = (TextView) findViewById(R.id.withDrawal_detail_commmit);
		withDrawal_detail_commmit.setOnClickListener(this);
		withDrawal_detail_money = (TextView) findViewById(R.id.withDrawal_detail_money);
		withDrawal_detail_instruction_txt = (TextView) findViewById(R.id.withDrawal_detail_instruction_txt);
	}

	@Override
	public void onClick(View v) {
		// TODO Auto-generated method stub
		int id = v.getId();
		if (id == R.id.withDrawal_detail_commmit) {

		finish();
		} else if(id==R.id.wallet_noData){
			 if(NetWorkUtil.getNetWorkInfoType(getApplicationContext())==NetWorkUtil.NONE){
					showToast("请检查网络是否连接！");	
					 loadError(true);
					}else{
						loadError(false);;
					}
		}
	
	}

}
